package com.lib.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * 描述：
 *
 * @author FengLing
 * Created On 2020-09-30 030
 */
public final class SPUtils {

    //<editor-fold desc="给外部使用的Key值">
    public static final String KEY_LAST_DOWNLOADED_SIZE = "last_downloaded_size";
    public static final String KEY_LAST_ACCOUNT = "u_a";
    public static final String KEY_LAST_TOKEN = "u_k";
    public static final String KEY_LOCATED_INFO = "l_info";
    public static final String KEY_LOCATED_CITY = "l_city";
    public static final String KEY_LOCATED_DISTRICT = "l_district";
    //</editor-fold>

    public static final String SP_DEFAULT_NAME = "defaultSP";
    public static final String FILE_NAME_UUID = ".uu.id";
    public static final String KEY_UUID = "uuid";

    private static Context sContext;

    private SPUtils() {
    }

    public static void init(Context context) {
        sContext = context.getApplicationContext();
    }

    public static SharedPreferences getSP() {
        if (sContext == null) {
            throw new NullPointerException("please call init first!");
        }
        return sContext.getSharedPreferences(SP_DEFAULT_NAME, Context.MODE_PRIVATE);
    }

    public static SharedPreferences getSP(String spName) {
        if (sContext == null) {
            throw new NullPointerException("please call init first!");
        }
        return sContext.getSharedPreferences(spName, Context.MODE_PRIVATE);
    }

//    private static class Inner {
//        private static final SPUtils mInstance = new SPUtils();
//    }
//
//    public static SPUtils getSp(String spName) {
//        return Inner.mInstance;
//    }
//
//    public SharedPreferences.Editor edit() {
//        return null;
//    }
}